package cn.com.header.core;

import java.io.Serializable;

/**
 * 统一定义id的entity基类.
 */
@SuppressWarnings("serial")
public class BaseEntity implements Serializable{
	/**
	 * 主键
	 */
	protected Long id;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public boolean equals(Object obj){
		if (obj == null)
			return false;
		if (!(obj instanceof BaseEntity))
			return false;
		
		BaseEntity entity = (BaseEntity)obj;
		if (!entity.getClass().equals(this.getClass()))
			return false;
		
		return this.getId() != null && this.getId().equals(entity.getId());
	}
	
	public String toString(){
		return String.format("%s:{id=%s}", this.getClass().getName(), id);
	}
}
